package com.sc.nft.controller;

import cn.hutool.core.bean.BeanUtil;
import com.sc.nft.annotation.UserLogin;
import com.sc.nft.entity.OpenPage;
import com.sc.nft.entity.vo.OpenPageVO;
import com.sc.nft.service.OpenPageService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/open")
@Api(tags ="开屏页")
public class OpenPageController {
    private final OpenPageService openPageService;


    @ApiOperation(value = "获取开屏页", notes = "获取开屏页", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getOpenPage", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<OpenPageVO> getOpenPage() {
        OpenPage one = openPageService.getOne();
        if (BeanUtil.isEmpty(one)) {
            OpenPageVO openPageVO = new OpenPageVO();
            return Result.success(openPageVO);
        }
        return Result.success(one, OpenPageVO.class);
    }

}
